<template>
  <div class="login-wrap">
    <div id="#blogsback">
      <div class="m-content">
        <el-menu
          :default-active="$route.path"
          class="el-menu-demo"
          mode="horizontal"
          router
        >
          <el-menu-item index="/home">博客首页</el-menu-item>
          <el-submenu index="2">
            <template #title>留言板</template>
            <el-menu-item index="/liuyan/liuyan">查看留言</el-menu-item>
            <el-menu-item index="/music/music">听听音乐</el-menu-item>
          </el-submenu>
          <el-menu-item index="/mine/mine">我的简历</el-menu-item>
          <el-menu-item index="/user/user">后台管理</el-menu-item>
          <el-menu-item index="/login">登录</el-menu-item>
        </el-menu>
      </div>

      <div>
        <h1 style="text-align: center; padding-left: 50px; color: #409EFF;">留言板</h1>
        <div style="text-align: center">
          <template>
            <div class="block">
              <el-timeline style="margin: 0 auto; max-width: 960px">
                <el-timeline-item
                  :timestamp="m.comment_date"
                  placement="top"
                  v-for="(m, index) in this.listData"
                  :key="index"
                >
                  <el-card>
                    <h4>{{ m.comment_content }}</h4>
                    <p>{{ m.comment_date }} 评论于 {{ m.blog_id }}</p>
                  </el-card>
                </el-timeline-item>
              </el-timeline>
            </div>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>




<script>
import { commentall, select, del, add, update } from "../../api/commentapi";
export default {
  name: "liuyan",
  data() {
    return {
      listData: [],
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      commentall().then((res) => {
        this.listData = res;
        console.log(res);
        for (var i = 0; i <= this.listData.length; i++) {
          this.listData[i].comment_date = this.GetDateFormat(
            this.listData[i].comment_date
          );
        }
      });
    },
    GetDateFormat(str) {
      return new Date(parseInt(str.substr(6, 13))).toLocaleDateString();
    },
  },
};
</script>
<style >
.login-wrap {
  width: 100%;
 
  background-image: url("../../assets/img/8.png");
  background-position: center right;
  background-size:cover;
}
#blogsback {
  margin: 0;
  padding: 0;

  height: 100%;
  max-width: 960px;
}
.m-content {
  margin: 0 auto;
  max-width: 960px;
  text-align: center;
}
.el-menu-demo {
  max-width: 960px;
  text-align: center;
  margin: 0 auto;
}
</style>